<?php
/**
 * 	app后台轮播
 *  =============================
 * 	后台父类
 * 	=============================
 *	Author: 褚天恩
 *  Date: 2017-10-09
 * @author Administrator
 *
 */
namespace app\walletyhbbadmin\controller;
use Think\Db;
class Art extends AdminBase{
	//空操作
	public function _initialize(){
		parent::_initialize();
	}
    /**
     *招贤纳士
     * 
     */
   	public function index(){
   	   $list = DB::name('team_type_recruit')->select();
   	   $this->assign('list',$list);
       return $this->fetch();
    }
//    修改
    public function articleClass()
    {
            $id = input('id');
            $res = DB::name('team_type_recruit')->where('id',$id)->find();
            $res1 = DB::name('team_type_recruit_us')->where('id',$id)->find();
            $res2 = DB::name('team_type_recruit_jp')->where('id',$id)->find();
            $this->assign('res',$res);
            $this->assign('res1',$res1);
            $this->assign('res2',$res2);
            return $this->fetch();
    }
    public function doedit()
    {
        $id = input('id');
        $data['title'] = input('title');
        $arr['title'] = input('utitle');
        $list['title'] = input('jtitle');

        $data['c_content'] = input('content');
        $arr['c_content'] = input('ucontent');
        $list['c_content'] = input('jcontent');
        $res = DB::name('team_type_recruit')->where('id',$id)->update($data);
        $res1 = DB::name('team_type_recruit_us')->where('id',$id)->update($arr);
        $res2 = DB::name('team_type_recruit_jp')->where('id',$id)->update($list);
        $this->success('操作成功','art/index');
    }
//    添加
    public function articleAdd()
    {
        return $this->fetch();
    }
    public function doarticleAdd()
    {
        $data['title'] = input('title');
        $arr['title'] = input('utitle');
        $list['title'] = input('jtitle');

        $data['c_content'] = input('content');
        $arr['c_content'] = input('ucontent');
        $list['c_content'] = input('jcontent');

        $data['time'] = time();
        $arr['time'] = time();
        $list['time'] = time();
        $resid = DB::name('team_type_recruit')->insertGetId($data);
        if($resid){
            $arr['id'] = $resid;
            $res1 = DB::name('team_type_recruit_us')->insert($arr);
            $list['id'] = $resid;
            $res2 = DB::name('team_type_recruit_jp')->insert($list);
            if($res1 && $res2)
            {
                $this->success('添加成功','art/index');
            }else{
                $this->error('系统繁忙,请稍后再试');
            }
        }
    }
//  删除
    public function del()
    {
        $id = input('id');
        $res = DB::name('team_type_recruit')->where('id',$id)->delete();
        $arr = DB::name('team_type_recruit_us')->where('id',$id)->delete();
        $list = DB::name('team_type_recruit_jp')->where('id',$id)->delete();
        if($res && $arr && $list)
        {
            $this->success('删除成功');
        }else{
            $this->error('系统繁忙,请稍后再试');
        }
    }
}